/**
 * Created by Administrator on 2017/8/12.
 */
var express=require('express');
var app=express();
var swig=require('swig');
var mongoose=require('mongoose');
app.engine('html',swig.renderFile);
app.set('views','./views');
app.set('view engine','html');
swig.setDefaults({cache:false});

app.use('/public',express.static(__dirname + '/public'));
app.use('/admin',require('./routers/admin'));
app.use('/api',require('./routers/api'));
app.use('/',require('./routers/main'));

mongoose.connect('mongodb://localhost:27018/blog',function (err) {
    if(err){
        console.log('数据库连接失败')
    }else {
        console.log('数据连接成功')
        app.listen(8081);
    }
});
